<template>
  <div>
    <div>
      <p v-for="(i, index) in list" :key="index">
        <van-button @click="showvideo(i.id)">{{ i.name }}</van-button>
      </p>
    </div>
    <van-dialog v-model="show" title="标题" show-cancel-button>
      <video with="320" height="240" controls autoplay>
        <source :src="url" type="video/mp4" />
      </video>
    </van-dialog>
    {{id}}
  </div>
</template>

<script>
export default {
    data(){
        return{
            list:[],
            show:false,
            id:this.$route.params.id,
            clist:{},
            url:"",
            userid:localStorage.getItem("userid")
        }
    },
    methods:{
        getdetail(){
            this.axios.get("/detail?id="+this.id)
            .then(res=>{
                this.list=res.data.jie
                this.clist=res.data.clist
            })
        },
        showvideo(id){
        this.axios.get("getVideo?id="+id+"&courseid="+this.id+"&userid="+this.userid)
        .then(res=>{
            if(res.data.code==200){
                this.url=res.data.url
                this.show=true
            }else{
                alert(res.data.mes)
            }
        })
    }
    },
    mounted(){
        this.getdetail()
    }
}
</script>

<style>

</style>